<?php
error_reporting (E_ALL & ~E_NOTICE);
session_start();
if($_SESSION['auth'] > 0)
{
?>
<script language="Javascript">
browser= navigator.appName;
if (browser == "Netscape")
window.location="home.php?page=bacheca"; else window.location="home.php?page=bacheca"
</script>
<?php
}
include 'connect.php';
$info = mysql_query ("Select * from info");
$info2 = mysql_fetch_array($info);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title><?php echo $info2['nome'] . ' ' . $info2['versione']; ?> - Login</title>
	<link rel="stylesheet" type="text/css" href="style.css" />
	<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
</head>
<body onLoad="document.login.user.focus()">
	<div id="header">
    	<img src="images/logo.png" id="logo">
      </div>
	<br>
	<center><table border="0"><tr><td>
	<fieldset id="login">
                    	<h4>Accedi al sistema</h4>
               			<form name="login" method="post">
                        	<p class="clearfix"><label for="username">Username:</label>
                            <input name="user" id="username" type="text" value="" onkeydown="if(event.keyCode==13) validateForm()" /></p>
                            <p class="clearfix"><label for="password">Password:</label>
							<input name="password" id="password" type="password" value="" onkeydown="if(event.keyCode==13) validateForm()" /></p>
                            <p class="clearfix check"><input type="checkbox" id="remember" name="remember" />
                            <label for="remember" id="remlabel">Ricordami</label>
                        <input id="submit1" type="button" onClick="validateForm()" /></p>
                    	</form>
                        <p class="member"><a href="#">Password dimenticata?</a><br />Non hai un account? <a href="#">Registrati adesso!</a></p>
      </fieldset></td>
	<td> &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp </td>
	<td><img src="images/globe.png"></td><tr></table></center>
     <br><br><br>
    <div id="footer">
        <p><?php echo $info2['nome'] . ' ' . $info2['versione']; ?></p>
    </div>
    
    <script language="javascript">
	function validateForm() 
	{
		//acquisisco il valore delle variabili
		var username = document.login.user.value;
		var password = document.login.password.value;
	    
		//controllo coerenza 
		if (username == "") 
		{
		   alert("Username obbligatorio!");
		   document.login.user.focus();
		   return false;
		}
		else if (password == "")
		{
		   alert("Password obbligatoria!");
		   document.login.password.focus();
		   return false;
		}
		//mando i dati alla pagina
		else 
		{
		   document.login.action = "login.php";
		   document.login.submit();
		}	
	}
	</script>
    
</body>
</html>
